package no.ntnu.idi.evaluering;
import no.ntnu.idi.deid.documentunits.Document;
import no.ntnu.idi.deid.documentunits.Token;
import no.ntnu.idi.deid.documentunits.TokenIterator;
import no.ntnu.idi.deid.preprocessor.Documents;

public class AnnotatedCorpus {
	
	private Documents mDocuments;
	
	public AnnotatedCorpus(Documents documents){
		mDocuments = documents;
		searchAllDocuments();
	}
	
//	public static Map<String, Boolean> generateGoldStandardMap(Document document) {
//			Map<String,Boolean> resultMap = new HashMap<String,Boolean>();
//			TokenIterator it = document.getTokenIterator();
//			while(it.hasNext()) {
//				Token token =  (Token) it.next();
//				resultMap.put(token.getOrginal(), getSensitivity(token.getOrginal()));
//			}
//		return resultMap;
//	}
	
	private void searchAllDocuments() {
		for(Document document: mDocuments) {
			searchDocument(document);
		}
	}
	
	private void searchDocument(Document document) {
		TokenIterator it = document.getTokenIterator();
		while(it.hasNext()) {
			Token token =  (Token) it.next();
			token.setSensetivityTag(getSensitivity(token.getOrginal()));
		}
	}
	
	private static boolean getSensitivity(String str) {
		if(str.endsWith(EvaluationConstants.SENSITIVTYMARK)) {
			return true;
		}
		else {
			return false;
		}
	}
	
	public void genereateGoldCorpusFiles() {
		EvaluationFile.generateFilesFrom(mDocuments);
	}
}
